﻿using MySql.Data.MySqlClient;
using System;

namespace EasyIot.Repository
{
    public class DbContext
    { 
        public static string ConnectionString { set; get; }

        public System.Data.IDbConnection GetConnection()
        {
            //string connectionString = configuration.GetValue<string>("Db:ConnectionString");
#if MYSQL
            var connection = new MySqlConnection(ConnectionString);
            connection.Open();
            return connection;
#endif
#if ORACLE
            var connection = new OracleConnection(connectionString);
            connection.Open();
            return connection;
#endif
#if SQLSERVER
            var connection = new SqlConnection(connectionString);
            connection.Open();
            return connection;
#endif
            throw new Exception("数据库类型错误");
        }

    }
}
